<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');?>
<script type="text/javascript">
var cats = <?php echo $cats_json; ?>;
$(function(){
	$("#catid_1").change(function(){
		var catid_1 = this.value;
		var html="<option value='all'>全部</option>";
		if(catid_1 == 'all') {
			$("#catid_2").html(html);
			return ;
		}
		for(i in cats) {
			if(cats[i].catid == catid_1) {
				for(j in cats[i].child) {
					html += "<option value='"+cats[i].child[j].catid+"'>"+cats[i].child[j].catname+"</option>";
				}
				$("#catid_2").html(html);
			}
		}
	});
});
</script>
<div class="pad_10">
<form name="searchform" action="" method="get" >
<input type="hidden" value="brand" name="m">
<input type="hidden" value="brand" name="c">
<input type="hidden" value="init" name="a">
<input type="hidden" value="<?php echo $_GET['menuid']; ?>" name="menuid">
<table width="100%" cellspacing="0" class="search-form">
    <tbody>
		<tr>
		<td>
		<div class="explain-col">
		所属栏目：<select name="info[catid_1]" id="catid_1">
					<option value="all">全部</option>
						<?php 
						foreach ($cats AS $v) {
							echo "<option value='".$v['catid']."' ".($_GET['info']['catid_1']==$v['catid'] ? ' selected':'').">".$v['catname']."</option>";
						}
						?>
				  </select>
				  <select name="info[catid_2]" id="catid_2">
				  	<option value="all">全部</option>
						<?php
						foreach ($cats[0]['child'] AS $v) {
							echo "<option value='".$v['catid']."' ".($_GET['info']['catid_2']==$v['catid'] ? ' selected':'').">".$v['catname']."</option>";
						}
						?>
				  </select>
		关联会员: <select name="info[userid]">
					<?php 
					foreach ($members AS $u) {
						echo "<option value='".$u['userid']."' ".($_GET['info']['userid']==$u['userid'] ? ' selected':'').">".$u['username']."</option>";
					}
					?>
				  </select>
		<input type="submit" name="search" class="button" value="<?php echo L('search')?>" />
	</div>
		</td>
		</tr>
    </tbody>
</table>
</form>
<div class="bk10"></div>
<div class="table-list">
    <table width="100%" cellspacing="0">
        <thead>
		<tr>
		<th width="6%">ID</th>
		<th align="left" >名称</th>
		<th align="left" >所属栏目</th>
		<th width="15%" align="left" >关联会员</th>
		<th width="10%" >创建时间</th>
		<th width="15%" >管理操作</th>
		</tr>
        </thead>
        <tbody>
		<?php 
		if(is_array($infos)){
			foreach($infos as $info){
		?>
		<tr>
		<td align="center"><?php echo $info['id']?></td>
		<td><?php echo ($info['parentid']>0 ? "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" : "").$info['name']?></td>
		<td><?php echo $info['top_catname']?></td>
		<td><?php echo $info['username']?></td>
		<td><?php echo date('Y-m-d H:i', $info['create_time']); ?></td>
		<td>
		<?php if ($info['parentid']==0) { ?>
		<a href="javascript:void(0);" onclick="addClass('<?php echo $info['id']; ?>','<?php echo new_addslashes($info['name']); ?>')">添加分类</a> | <a href="javascript:void(0);" onclick="edit('<?php echo $info['id']?>','<?php echo new_addslashes($info['name'])?>')"><?php echo L('edit')?></a> | <a href="javascript:confirmurl('?m=brand&c=brand&a=delete&bid=<?php echo $info['id']?>', '确认删除？')"><?php echo L('delete')?></a>
		<?php } else {?>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="editClass('<?php echo $info['id']?>','<?php echo new_addslashes($info['name'])?>')"><?php echo L('edit')?></a> | <a href="javascript:confirmurl('?m=brand&c=brand&a=delete&bid=<?php echo $info['id']?>', '确认删除？')"><?php echo L('delete')?></a>
		<?php }?>
		</td>
		</tr>
		<?php 
			}
		}
		?>
</tbody>
</table>
</div>
<div id="pages"><?php echo $pages?></div>
</div>
<script type="text/javascript">
<!--
	window.top.$('#display_center_id').css('display','none');
function edit(id, name) {
	window.top.art.dialog({id:'edit'}).close();
	window.top.art.dialog({title:name,id:'edit',iframe:'?m=brand&c=brand&a=edit&bid='+id,width:'500',height:'400'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
}
function addClass(id, name) {
	window.top.art.dialog({id:'addClass'}).close();
	window.top.art.dialog({title:name+' 添加分类',id:'addClass',iframe:'?m=brand&c=brand&a=addClass&bid='+id,width:'500',height:'100'}, function(){var d = window.top.art.dialog({id:'addClass'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'addClass'}).close()});
}
function editClass(id, name) {
	window.top.art.dialog({id:'editClass'}).close();
	window.top.art.dialog({title:name,id:'editClass',iframe:'?m=brand&c=brand&a=editClass&bid='+id,width:'500',height:'250'}, function(){var d = window.top.art.dialog({id:'editClass'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'editClass'}).close()});
}
//-->
</script>
</body>
</html>